<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/><meta name="exporter-version" content="Evernote Mac 9.1.3 (458534)"/><meta name="author" content="流星"/><meta name="created" content="2020-10-26 11:40:15 +0000"/><meta name="source" content="desktop.mac"/><meta name="updated" content="2020-10-26 11:50:52 +0000"/><meta name="content-class" content="yinxiang.markdown"/><title>读懂 ECMAScript 规格</title></head><body><div style="font-size: 14px; margin: 0; padding: 0; width: 100%;"><h4 style="line-height: 160%; box-sizing: content-box; font-size: 20px; color: #333;">概述</h4>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">规格文件是计算机语言的官方标准，详细描述语法规则和实现方法。<br/>
如果你遇到疑难的语法问题，实在找不到答案， 这时可以去查看规格文件，了解语言标准是怎么说的。规格是解决问题 的“最后一招”。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">因为JavaScript的使用场景复杂，语法规则不统 一，例外很多，各种运行环境的行为不一致，导致奇怪的语法问题层出 不穷，任何语法书都不可能囊括所有情况。查看规格，不失为一种解决 语法问题的最可靠、最权威的终极方法。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">CMAScript 6的规格，可以在ECMA国际标准组织的官方网站<br/>
(www.ecma-international.org/ecma-262/6.0/)免费下载和在线阅读。</p>
<h4 style="line-height: 160%; box-sizing: content-box; font-size: 20px; color: #333;">相等运算符</h4>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">相等运算符( == )是一个很让人头痛的运算符，它的语法行为多变， 不符合直觉。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">判断表达式 0==null 的值</p>
<pre style="line-height: 160%; box-sizing: content-box; border: 0; border-radius: 0; margin: 2px 0 8px; background-color: #f5f7f8;"><code style="display: block; overflow-x: auto; background: #1e1e1e; line-height: 160%; box-sizing: content-box; border: 0; border-radius: 0; letter-spacing: -.3px; padding: 18px; color: #f4f4f4; white-space: pre-wrap;">1. 如果x 不是正常值(比如抛出一个错误)，中断执行。
2. 如果y 不是正常值，中断执行。
3. 如果 Type(x) 与 Type(y) 相同，执行严格相等运算 x ===
y。
4. 如果x是null，y是undefined，返回true。
5. 如果x是undefined，y是null，返回true。
6. 如果 Type(x) 是数值， Type(y) 是字符串，返回 x ==
ToNumber(y) 的结果。
7. 如果 Type(x) 是字符串， Type(y) 是数值，返
回 ToNumber(x) == y 的结果。
8. 如果 Type(x) 是布尔值，返回 ToNumber(x) == y 的结果。
9. 如果 Type(y) 是布尔值，返回 x == ToNumber(y) 的结果。
10. 如果 Type(x) 是字符串或数值或 Symbol 值， Type(y) 是对 象，返回 x == ToPrimitive(y) 的结果。
11. 如果 Type(x) 是对象， Type(y) 是字符串或数值
或 Symbol 值，返回 ToPrimitive(x) == y 的结果。
12. 返回 false 。

</code></pre>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">由于 0 的类型是数值， null 的类型是Null(这是规格4.3.13小节的规 定，是内部Type运算的结果，跟 typeof 运算符无关)。因此上面的前 11步都得不到结果，要到第12步才能得到 false 。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">0==null //false</p>
<h4 style="line-height: 160%; box-sizing: content-box; font-size: 20px; color: #333;">数组的空位</h4>
<pre style="line-height: 160%; box-sizing: content-box; border: 0; border-radius: 0; margin: 2px 0 8px; background-color: #f5f7f8;"><code style="display: block; overflow-x: auto; background: #1e1e1e; line-height: 160%; box-sizing: content-box; border: 0; border-radius: 0; letter-spacing: -.3px; padding: 18px; color: #f4f4f4; white-space: pre-wrap;">const a1 = [undefined, undefined, undefined];
const a2 = [, , ,];
a1.length // 3
a2.length // 3
a1[0] // undefined
a2[0] // undefined
a1[0] === a2[0] // true


0 in a1 // true
0 in a2 // false
a1.hasOwnProperty(0) // true
a2.hasOwnProperty(0) // false
Object.keys(a1) // ["0", "1", "2"]
Object.keys(a2) // []
a1.map(n =&gt; 1) // [1, 1, 1]
a2.map(n =&gt; 1) // [, , ,]
</code></pre>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">为什么 a1 与 a2 成员的行为不一致?数组的成员是 undefined 或空 位，到底有什么不同?</p>
<pre style="line-height: 160%; box-sizing: content-box; border: 0; border-radius: 0; margin: 2px 0 8px; background-color: #f5f7f8;"><code style="display: block; overflow-x: auto; background: #1e1e1e; line-height: 160%; box-sizing: content-box; border: 0; border-radius: 0; letter-spacing: -.3px; padding: 18px; color: #f4f4f4; white-space: pre-wrap;">“数组成员可以省略。只要逗号前面没有任何表达式，数组
的 length 属性就会加1，并且相应增加其后成员的位置索引。被省略的成员不会被定义。如果被省略的成员是数组最后一个成员，则不 会导致数组 length 属性增加。”
</code></pre>
<h4 style="line-height: 160%; box-sizing: content-box; font-size: 20px; color: #333;">数组的map方法</h4>
<pre style="line-height: 160%; box-sizing: content-box; border: 0; border-radius: 0; margin: 2px 0 8px; background-color: #f5f7f8;"><code style="display: block; overflow-x: auto; background: #1e1e1e; line-height: 160%; box-sizing: content-box; border: 0; border-radius: 0; letter-spacing: -.3px; padding: 18px; color: #f4f4f4; white-space: pre-wrap;">1. 得到当前数组的 this 对象
2. 如果报错就返回
3. 求出当前数组的 length 属性
4. 如果报错就返回
5. 如果map方法的参数 callbackfn 不可执行，就报错
6. 如果map方法的参数之中，指定了 this ，就让 T 等于该参
数，否则 T 为 undefined
7. 生成一个新的数组 A ，跟当前数组的 length 属性保持一致
8. 如果报错就返回
9. 设定 k 等于0
10. 只要 k 小于当前数组的 length 属性，就重复下面步骤
    a. 设定 Pk 等于 ToString(k) ，即将 K 转为字符串
    b. 设定 kPresent 等于 HasProperty(O, Pk) ，即求当前数组 有没有指定属性
    c. 如果报错就返回
    d. 如果 kPresent 等于 true ，则进行下面步骤
    d-1. 设定 kValue 等于 Get(O, Pk) ，取出当前数组的指定属性 d-2. 如果报错就返回
    d-3. 设定 mappedValue 等于 Call(callbackfn, T, «kValue, k, O») ，即执行回调函数
    d-4. 如果报错就返回
    d-5. 设定 status 等于 CreateDataPropertyOrThrow (A, Pk, mappedValue) ，即将回调函数的值放入 A 数组的指定位置
    d-6. 如果报错就返回
    e. k 增加1
11. 返回 A


const arr = [, , ,];
arr.map(n =&gt; {
  console.log(n);
  return 1;
}) // [, , ,]
</code></pre>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">上面代码中， arr 是一个全是空位的数组， map 方法遍历成员时，发 现是空位，就直接跳过，不会进入回调函数。因此，回调函数里面<br/>
的 console.log 语句根本不会执行，整个 map 方法返回一个全是空位 的新数组。</p>
</div><center style="display:none !important;visibility:collapse !important;height:0 !important;white-space:nowrap;width:100%;overflow:hidden">%23%23%23%23%20%E6%A6%82%E8%BF%B0%0A%E8%A7%84%E6%A0%BC%E6%96%87%E4%BB%B6%E6%98%AF%E8%AE%A1%E7%AE%97%E6%9C%BA%E8%AF%AD%E8%A8%80%E7%9A%84%E5%AE%98%E6%96%B9%E6%A0%87%E5%87%86%EF%BC%8C%E8%AF%A6%E7%BB%86%E6%8F%8F%E8%BF%B0%E8%AF%AD%E6%B3%95%E8%A7%84%E5%88%99%E5%92%8C%E5%AE%9E%E7%8E%B0%E6%96%B9%E6%B3%95%E3%80%82%0A%E5%A6%82%E6%9E%9C%E4%BD%A0%E9%81%87%E5%88%B0%E7%96%91%E9%9A%BE%E7%9A%84%E8%AF%AD%E6%B3%95%E9%97%AE%E9%A2%98%EF%BC%8C%E5%AE%9E%E5%9C%A8%E6%89%BE%E4%B8%8D%E5%88%B0%E7%AD%94%E6%A1%88%EF%BC%8C%20%E8%BF%99%E6%97%B6%E5%8F%AF%E4%BB%A5%E5%8E%BB%E6%9F%A5%E7%9C%8B%E8%A7%84%E6%A0%BC%E6%96%87%E4%BB%B6%EF%BC%8C%E4%BA%86%E8%A7%A3%E8%AF%AD%E8%A8%80%E6%A0%87%E5%87%86%E6%98%AF%E6%80%8E%E4%B9%88%E8%AF%B4%E7%9A%84%E3%80%82%E8%A7%84%E6%A0%BC%E6%98%AF%E8%A7%A3%E5%86%B3%E9%97%AE%E9%A2%98%20%E7%9A%84%E2%80%9C%E6%9C%80%E5%90%8E%E4%B8%80%E6%8B%9B%E2%80%9D%E3%80%82%0A%0A%E5%9B%A0%E4%B8%BAJavaScript%E7%9A%84%E4%BD%BF%E7%94%A8%E5%9C%BA%E6%99%AF%E5%A4%8D%E6%9D%82%EF%BC%8C%E8%AF%AD%E6%B3%95%E8%A7%84%E5%88%99%E4%B8%8D%E7%BB%9F%20%E4%B8%80%EF%BC%8C%E4%BE%8B%E5%A4%96%E5%BE%88%E5%A4%9A%EF%BC%8C%E5%90%84%E7%A7%8D%E8%BF%90%E8%A1%8C%E7%8E%AF%E5%A2%83%E7%9A%84%E8%A1%8C%E4%B8%BA%E4%B8%8D%E4%B8%80%E8%87%B4%EF%BC%8C%E5%AF%BC%E8%87%B4%E5%A5%87%E6%80%AA%E7%9A%84%E8%AF%AD%E6%B3%95%E9%97%AE%E9%A2%98%E5%B1%82%E5%87%BA%20%E4%B8%8D%E7%A9%B7%EF%BC%8C%E4%BB%BB%E4%BD%95%E8%AF%AD%E6%B3%95%E4%B9%A6%E9%83%BD%E4%B8%8D%E5%8F%AF%E8%83%BD%E5%9B%8A%E6%8B%AC%E6%89%80%E6%9C%89%E6%83%85%E5%86%B5%E3%80%82%E6%9F%A5%E7%9C%8B%E8%A7%84%E6%A0%BC%EF%BC%8C%E4%B8%8D%E5%A4%B1%E4%B8%BA%E4%B8%80%E7%A7%8D%E8%A7%A3%E5%86%B3%20%E8%AF%AD%E6%B3%95%E9%97%AE%E9%A2%98%E7%9A%84%E6%9C%80%E5%8F%AF%E9%9D%A0%E3%80%81%E6%9C%80%E6%9D%83%E5%A8%81%E7%9A%84%E7%BB%88%E6%9E%81%E6%96%B9%E6%B3%95%E3%80%82%0A%0ACMAScript%206%E7%9A%84%E8%A7%84%E6%A0%BC%EF%BC%8C%E5%8F%AF%E4%BB%A5%E5%9C%A8ECMA%E5%9B%BD%E9%99%85%E6%A0%87%E5%87%86%E7%BB%84%E7%BB%87%E7%9A%84%E5%AE%98%E6%96%B9%E7%BD%91%E7%AB%99%0A(www.ecma-international.org%2Fecma-262%2F6.0%2F)%E5%85%8D%E8%B4%B9%E4%B8%8B%E8%BD%BD%E5%92%8C%E5%9C%A8%E7%BA%BF%E9%98%85%E8%AF%BB%E3%80%82%0A%0A%23%23%23%23%20%E7%9B%B8%E7%AD%89%E8%BF%90%E7%AE%97%E7%AC%A6%0A%E7%9B%B8%E7%AD%89%E8%BF%90%E7%AE%97%E7%AC%A6(%20%3D%3D%20)%E6%98%AF%E4%B8%80%E4%B8%AA%E5%BE%88%E8%AE%A9%E4%BA%BA%E5%A4%B4%E7%97%9B%E7%9A%84%E8%BF%90%E7%AE%97%E7%AC%A6%EF%BC%8C%E5%AE%83%E7%9A%84%E8%AF%AD%E6%B3%95%E8%A1%8C%E4%B8%BA%E5%A4%9A%E5%8F%98%EF%BC%8C%20%E4%B8%8D%E7%AC%A6%E5%90%88%E7%9B%B4%E8%A7%89%E3%80%82%0A%0A%E5%88%A4%E6%96%AD%E8%A1%A8%E8%BE%BE%E5%BC%8F%200%3D%3Dnull%20%E7%9A%84%E5%80%BC%20%0A%0A%60%60%60%0A1.%20%E5%A6%82%E6%9E%9Cx%20%E4%B8%8D%E6%98%AF%E6%AD%A3%E5%B8%B8%E5%80%BC(%E6%AF%94%E5%A6%82%E6%8A%9B%E5%87%BA%E4%B8%80%E4%B8%AA%E9%94%99%E8%AF%AF)%EF%BC%8C%E4%B8%AD%E6%96%AD%E6%89%A7%E8%A1%8C%E3%80%82%0A2.%20%E5%A6%82%E6%9E%9Cy%20%E4%B8%8D%E6%98%AF%E6%AD%A3%E5%B8%B8%E5%80%BC%EF%BC%8C%E4%B8%AD%E6%96%AD%E6%89%A7%E8%A1%8C%E3%80%82%0A3.%20%E5%A6%82%E6%9E%9C%20Type(x)%20%E4%B8%8E%20Type(y)%20%E7%9B%B8%E5%90%8C%EF%BC%8C%E6%89%A7%E8%A1%8C%E4%B8%A5%E6%A0%BC%E7%9B%B8%E7%AD%89%E8%BF%90%E7%AE%97%20x%20%3D%3D%3D%0Ay%E3%80%82%0A4.%20%E5%A6%82%E6%9E%9Cx%E6%98%AFnull%EF%BC%8Cy%E6%98%AFundefined%EF%BC%8C%E8%BF%94%E5%9B%9Etrue%E3%80%82%0A5.%20%E5%A6%82%E6%9E%9Cx%E6%98%AFundefined%EF%BC%8Cy%E6%98%AFnull%EF%BC%8C%E8%BF%94%E5%9B%9Etrue%E3%80%82%0A6.%20%E5%A6%82%E6%9E%9C%20Type(x)%20%E6%98%AF%E6%95%B0%E5%80%BC%EF%BC%8C%20Type(y)%20%E6%98%AF%E5%AD%97%E7%AC%A6%E4%B8%B2%EF%BC%8C%E8%BF%94%E5%9B%9E%20x%20%3D%3D%0AToNumber(y)%20%E7%9A%84%E7%BB%93%E6%9E%9C%E3%80%82%0A7.%20%E5%A6%82%E6%9E%9C%20Type(x)%20%E6%98%AF%E5%AD%97%E7%AC%A6%E4%B8%B2%EF%BC%8C%20Type(y)%20%E6%98%AF%E6%95%B0%E5%80%BC%EF%BC%8C%E8%BF%94%0A%E5%9B%9E%20ToNumber(x)%20%3D%3D%20y%20%E7%9A%84%E7%BB%93%E6%9E%9C%E3%80%82%0A8.%20%E5%A6%82%E6%9E%9C%20Type(x)%20%E6%98%AF%E5%B8%83%E5%B0%94%E5%80%BC%EF%BC%8C%E8%BF%94%E5%9B%9E%20ToNumber(x)%20%3D%3D%20y%20%E7%9A%84%E7%BB%93%E6%9E%9C%E3%80%82%0A9.%20%E5%A6%82%E6%9E%9C%20Type(y)%20%E6%98%AF%E5%B8%83%E5%B0%94%E5%80%BC%EF%BC%8C%E8%BF%94%E5%9B%9E%20x%20%3D%3D%20ToNumber(y)%20%E7%9A%84%E7%BB%93%E6%9E%9C%E3%80%82%0A10.%20%E5%A6%82%E6%9E%9C%20Type(x)%20%E6%98%AF%E5%AD%97%E7%AC%A6%E4%B8%B2%E6%88%96%E6%95%B0%E5%80%BC%E6%88%96%20Symbol%20%E5%80%BC%EF%BC%8C%20Type(y)%20%E6%98%AF%E5%AF%B9%20%E8%B1%A1%EF%BC%8C%E8%BF%94%E5%9B%9E%20x%20%3D%3D%20ToPrimitive(y)%20%E7%9A%84%E7%BB%93%E6%9E%9C%E3%80%82%0A11.%20%E5%A6%82%E6%9E%9C%20Type(x)%20%E6%98%AF%E5%AF%B9%E8%B1%A1%EF%BC%8C%20Type(y)%20%E6%98%AF%E5%AD%97%E7%AC%A6%E4%B8%B2%E6%88%96%E6%95%B0%E5%80%BC%0A%E6%88%96%20Symbol%20%E5%80%BC%EF%BC%8C%E8%BF%94%E5%9B%9E%20ToPrimitive(x)%20%3D%3D%20y%20%E7%9A%84%E7%BB%93%E6%9E%9C%E3%80%82%0A12.%20%E8%BF%94%E5%9B%9E%20false%20%E3%80%82%0A%0A%60%60%60%0A%E7%94%B1%E4%BA%8E%200%20%E7%9A%84%E7%B1%BB%E5%9E%8B%E6%98%AF%E6%95%B0%E5%80%BC%EF%BC%8C%20null%20%E7%9A%84%E7%B1%BB%E5%9E%8B%E6%98%AFNull(%E8%BF%99%E6%98%AF%E8%A7%84%E6%A0%BC4.3.13%E5%B0%8F%E8%8A%82%E7%9A%84%E8%A7%84%20%E5%AE%9A%EF%BC%8C%E6%98%AF%E5%86%85%E9%83%A8Type%E8%BF%90%E7%AE%97%E7%9A%84%E7%BB%93%E6%9E%9C%EF%BC%8C%E8%B7%9F%20typeof%20%E8%BF%90%E7%AE%97%E7%AC%A6%E6%97%A0%E5%85%B3)%E3%80%82%E5%9B%A0%E6%AD%A4%E4%B8%8A%E9%9D%A2%E7%9A%84%E5%89%8D%2011%E6%AD%A5%E9%83%BD%E5%BE%97%E4%B8%8D%E5%88%B0%E7%BB%93%E6%9E%9C%EF%BC%8C%E8%A6%81%E5%88%B0%E7%AC%AC12%E6%AD%A5%E6%89%8D%E8%83%BD%E5%BE%97%E5%88%B0%20false%20%E3%80%82%0A%0A0%3D%3Dnull%20%2F%2Ffalse%0A%0A%0A%23%23%23%23%20%E6%95%B0%E7%BB%84%E7%9A%84%E7%A9%BA%E4%BD%8D%0A%60%60%60%0Aconst%20a1%20%3D%20%5Bundefined%2C%20undefined%2C%20undefined%5D%3B%0Aconst%20a2%20%3D%20%5B%2C%20%2C%20%2C%5D%3B%0Aa1.length%20%2F%2F%203%0Aa2.length%20%2F%2F%203%0Aa1%5B0%5D%20%2F%2F%20undefined%0Aa2%5B0%5D%20%2F%2F%20undefined%0Aa1%5B0%5D%20%3D%3D%3D%20a2%5B0%5D%20%2F%2F%20true%0A%0A%0A0%20in%20a1%20%2F%2F%20true%0A0%20in%20a2%20%2F%2F%20false%0Aa1.hasOwnProperty(0)%20%2F%2F%20true%0Aa2.hasOwnProperty(0)%20%2F%2F%20false%0AObject.keys(a1)%20%2F%2F%20%5B%220%22%2C%20%221%22%2C%20%222%22%5D%0AObject.keys(a2)%20%2F%2F%20%5B%5D%0Aa1.map(n%20%3D%3E%201)%20%2F%2F%20%5B1%2C%201%2C%201%5D%0Aa2.map(n%20%3D%3E%201)%20%2F%2F%20%5B%2C%20%2C%20%2C%5D%0A%60%60%60%0A%0A%E4%B8%BA%E4%BB%80%E4%B9%88%20a1%20%E4%B8%8E%20a2%20%E6%88%90%E5%91%98%E7%9A%84%E8%A1%8C%E4%B8%BA%E4%B8%8D%E4%B8%80%E8%87%B4%3F%E6%95%B0%E7%BB%84%E7%9A%84%E6%88%90%E5%91%98%E6%98%AF%20undefined%20%E6%88%96%E7%A9%BA%20%E4%BD%8D%EF%BC%8C%E5%88%B0%E5%BA%95%E6%9C%89%E4%BB%80%E4%B9%88%E4%B8%8D%E5%90%8C%3F%0A%0A%60%60%60%0A%E2%80%9C%E6%95%B0%E7%BB%84%E6%88%90%E5%91%98%E5%8F%AF%E4%BB%A5%E7%9C%81%E7%95%A5%E3%80%82%E5%8F%AA%E8%A6%81%E9%80%97%E5%8F%B7%E5%89%8D%E9%9D%A2%E6%B2%A1%E6%9C%89%E4%BB%BB%E4%BD%95%E8%A1%A8%E8%BE%BE%E5%BC%8F%EF%BC%8C%E6%95%B0%E7%BB%84%0A%E7%9A%84%20length%20%E5%B1%9E%E6%80%A7%E5%B0%B1%E4%BC%9A%E5%8A%A01%EF%BC%8C%E5%B9%B6%E4%B8%94%E7%9B%B8%E5%BA%94%E5%A2%9E%E5%8A%A0%E5%85%B6%E5%90%8E%E6%88%90%E5%91%98%E7%9A%84%E4%BD%8D%E7%BD%AE%E7%B4%A2%E5%BC%95%E3%80%82%E8%A2%AB%E7%9C%81%E7%95%A5%E7%9A%84%E6%88%90%E5%91%98%E4%B8%8D%E4%BC%9A%E8%A2%AB%E5%AE%9A%E4%B9%89%E3%80%82%E5%A6%82%E6%9E%9C%E8%A2%AB%E7%9C%81%E7%95%A5%E7%9A%84%E6%88%90%E5%91%98%E6%98%AF%E6%95%B0%E7%BB%84%E6%9C%80%E5%90%8E%E4%B8%80%E4%B8%AA%E6%88%90%E5%91%98%EF%BC%8C%E5%88%99%E4%B8%8D%20%E4%BC%9A%E5%AF%BC%E8%87%B4%E6%95%B0%E7%BB%84%20length%20%E5%B1%9E%E6%80%A7%E5%A2%9E%E5%8A%A0%E3%80%82%E2%80%9D%0A%60%60%60%0A%0A%0A%23%23%23%23%20%E6%95%B0%E7%BB%84%E7%9A%84map%E6%96%B9%E6%B3%95%0A%60%60%60%0A1.%20%E5%BE%97%E5%88%B0%E5%BD%93%E5%89%8D%E6%95%B0%E7%BB%84%E7%9A%84%20this%20%E5%AF%B9%E8%B1%A1%0A2.%20%E5%A6%82%E6%9E%9C%E6%8A%A5%E9%94%99%E5%B0%B1%E8%BF%94%E5%9B%9E%0A3.%20%E6%B1%82%E5%87%BA%E5%BD%93%E5%89%8D%E6%95%B0%E7%BB%84%E7%9A%84%20length%20%E5%B1%9E%E6%80%A7%0A4.%20%E5%A6%82%E6%9E%9C%E6%8A%A5%E9%94%99%E5%B0%B1%E8%BF%94%E5%9B%9E%0A5.%20%E5%A6%82%E6%9E%9Cmap%E6%96%B9%E6%B3%95%E7%9A%84%E5%8F%82%E6%95%B0%20callbackfn%20%E4%B8%8D%E5%8F%AF%E6%89%A7%E8%A1%8C%EF%BC%8C%E5%B0%B1%E6%8A%A5%E9%94%99%0A6.%20%E5%A6%82%E6%9E%9Cmap%E6%96%B9%E6%B3%95%E7%9A%84%E5%8F%82%E6%95%B0%E4%B9%8B%E4%B8%AD%EF%BC%8C%E6%8C%87%E5%AE%9A%E4%BA%86%20this%20%EF%BC%8C%E5%B0%B1%E8%AE%A9%20T%20%E7%AD%89%E4%BA%8E%E8%AF%A5%E5%8F%82%0A%E6%95%B0%EF%BC%8C%E5%90%A6%E5%88%99%20T%20%E4%B8%BA%20undefined%0A7.%20%E7%94%9F%E6%88%90%E4%B8%80%E4%B8%AA%E6%96%B0%E7%9A%84%E6%95%B0%E7%BB%84%20A%20%EF%BC%8C%E8%B7%9F%E5%BD%93%E5%89%8D%E6%95%B0%E7%BB%84%E7%9A%84%20length%20%E5%B1%9E%E6%80%A7%E4%BF%9D%E6%8C%81%E4%B8%80%E8%87%B4%0A8.%20%E5%A6%82%E6%9E%9C%E6%8A%A5%E9%94%99%E5%B0%B1%E8%BF%94%E5%9B%9E%0A9.%20%E8%AE%BE%E5%AE%9A%20k%20%E7%AD%89%E4%BA%8E0%0A10.%20%E5%8F%AA%E8%A6%81%20k%20%E5%B0%8F%E4%BA%8E%E5%BD%93%E5%89%8D%E6%95%B0%E7%BB%84%E7%9A%84%20length%20%E5%B1%9E%E6%80%A7%EF%BC%8C%E5%B0%B1%E9%87%8D%E5%A4%8D%E4%B8%8B%E9%9D%A2%E6%AD%A5%E9%AA%A4%0A%20%20%20%20a.%20%E8%AE%BE%E5%AE%9A%20Pk%20%E7%AD%89%E4%BA%8E%20ToString(k)%20%EF%BC%8C%E5%8D%B3%E5%B0%86%20K%20%E8%BD%AC%E4%B8%BA%E5%AD%97%E7%AC%A6%E4%B8%B2%0A%20%20%20%20b.%20%E8%AE%BE%E5%AE%9A%20kPresent%20%E7%AD%89%E4%BA%8E%20HasProperty(O%2C%20Pk)%20%EF%BC%8C%E5%8D%B3%E6%B1%82%E5%BD%93%E5%89%8D%E6%95%B0%E7%BB%84%20%E6%9C%89%E6%B2%A1%E6%9C%89%E6%8C%87%E5%AE%9A%E5%B1%9E%E6%80%A7%0A%20%20%20%20c.%20%E5%A6%82%E6%9E%9C%E6%8A%A5%E9%94%99%E5%B0%B1%E8%BF%94%E5%9B%9E%0A%20%20%20%20d.%20%E5%A6%82%E6%9E%9C%20kPresent%20%E7%AD%89%E4%BA%8E%20true%20%EF%BC%8C%E5%88%99%E8%BF%9B%E8%A1%8C%E4%B8%8B%E9%9D%A2%E6%AD%A5%E9%AA%A4%0A%20%20%20%20d-1.%20%E8%AE%BE%E5%AE%9A%20kValue%20%E7%AD%89%E4%BA%8E%20Get(O%2C%20Pk)%20%EF%BC%8C%E5%8F%96%E5%87%BA%E5%BD%93%E5%89%8D%E6%95%B0%E7%BB%84%E7%9A%84%E6%8C%87%E5%AE%9A%E5%B1%9E%E6%80%A7%20d-2.%20%E5%A6%82%E6%9E%9C%E6%8A%A5%E9%94%99%E5%B0%B1%E8%BF%94%E5%9B%9E%0A%20%20%20%20d-3.%20%E8%AE%BE%E5%AE%9A%20mappedValue%20%E7%AD%89%E4%BA%8E%20Call(callbackfn%2C%20T%2C%20%C2%ABkValue%2C%20k%2C%20O%C2%BB)%20%EF%BC%8C%E5%8D%B3%E6%89%A7%E8%A1%8C%E5%9B%9E%E8%B0%83%E5%87%BD%E6%95%B0%0A%20%20%20%20d-4.%20%E5%A6%82%E6%9E%9C%E6%8A%A5%E9%94%99%E5%B0%B1%E8%BF%94%E5%9B%9E%0A%20%20%20%20d-5.%20%E8%AE%BE%E5%AE%9A%20status%20%E7%AD%89%E4%BA%8E%20CreateDataPropertyOrThrow%20(A%2C%20Pk%2C%20mappedValue)%20%EF%BC%8C%E5%8D%B3%E5%B0%86%E5%9B%9E%E8%B0%83%E5%87%BD%E6%95%B0%E7%9A%84%E5%80%BC%E6%94%BE%E5%85%A5%20A%20%E6%95%B0%E7%BB%84%E7%9A%84%E6%8C%87%E5%AE%9A%E4%BD%8D%E7%BD%AE%0A%20%20%20%20d-6.%20%E5%A6%82%E6%9E%9C%E6%8A%A5%E9%94%99%E5%B0%B1%E8%BF%94%E5%9B%9E%0A%20%20%20%20e.%20k%20%E5%A2%9E%E5%8A%A01%0A11.%20%E8%BF%94%E5%9B%9E%20A%0A%0A%0Aconst%20arr%20%3D%20%5B%2C%20%2C%20%2C%5D%3B%0Aarr.map(n%20%3D%3E%20%7B%0A%20%20console.log(n)%3B%0A%20%20return%201%3B%0A%7D)%20%2F%2F%20%5B%2C%20%2C%20%2C%5D%0A%60%60%60%0A%E4%B8%8A%E9%9D%A2%E4%BB%A3%E7%A0%81%E4%B8%AD%EF%BC%8C%20arr%20%E6%98%AF%E4%B8%80%E4%B8%AA%E5%85%A8%E6%98%AF%E7%A9%BA%E4%BD%8D%E7%9A%84%E6%95%B0%E7%BB%84%EF%BC%8C%20map%20%E6%96%B9%E6%B3%95%E9%81%8D%E5%8E%86%E6%88%90%E5%91%98%E6%97%B6%EF%BC%8C%E5%8F%91%20%E7%8E%B0%E6%98%AF%E7%A9%BA%E4%BD%8D%EF%BC%8C%E5%B0%B1%E7%9B%B4%E6%8E%A5%E8%B7%B3%E8%BF%87%EF%BC%8C%E4%B8%8D%E4%BC%9A%E8%BF%9B%E5%85%A5%E5%9B%9E%E8%B0%83%E5%87%BD%E6%95%B0%E3%80%82%E5%9B%A0%E6%AD%A4%EF%BC%8C%E5%9B%9E%E8%B0%83%E5%87%BD%E6%95%B0%E9%87%8C%E9%9D%A2%0A%E7%9A%84%20console.log%20%E8%AF%AD%E5%8F%A5%E6%A0%B9%E6%9C%AC%E4%B8%8D%E4%BC%9A%E6%89%A7%E8%A1%8C%EF%BC%8C%E6%95%B4%E4%B8%AA%20map%20%E6%96%B9%E6%B3%95%E8%BF%94%E5%9B%9E%E4%B8%80%E4%B8%AA%E5%85%A8%E6%98%AF%E7%A9%BA%E4%BD%8D%20%E7%9A%84%E6%96%B0%E6%95%B0%E7%BB%84%E3%80%82</center></body></html>